//
//  GradientCell.swift
//  Swift30Days
//
//  Created by licheng ke on 2017/3/7.
//  Copyright © 2017年 licheng ke. All rights reserved.
//

import UIKit

class GradientCell: UITableViewCell {

    let gradient = CAGradientLayer();
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }
    
    override  init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier);
        
        // 设置影响的范围
        gradient.frame = self.bounds
        let color1 = UIColor(white: 1.0, alpha: 0.2).cgColor as CGColor
        let color2 = UIColor(white: 1.0, alpha: 0.1).cgColor as CGColor
        let color3 = UIColor.clear.cgColor as CGColor
        let color4 = UIColor(white: 0.0, alpha: 0.05).cgColor as CGColor
        
        gradient.colors = [color1, color2, color3, color4]
        gradient.locations = [0.0, 0.04, 0.95, 1.0]
        layer.insertSublayer(gradient, at: 0);
        textLabel?.textColor = .white;
        textLabel?.font =  UIFont(name: "Avenir Next", size: 18)
        selectionStyle = .none;
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews();
        gradient.frame = self.bounds;
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
